﻿@using DLMemberPointMS.Common
@using DLMemberPointMS.Entity.DTOModel
@{
    Layout = null;
}
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <link rel="stylesheet" type="text/css" href="https://www.layuicdn.com/layui/css/layui.css" />
    @*<link rel="stylesheet" type="text/css" href="~/layui/css/layui.css" />
        <script src="~/layui/layui.js" type="text/javascript" charset="utf-8"></script>*@
    <script src="~/layui/jquery-3.4.1.js" type="text/javascript" charset="utf-8"></script>
    <link rel="shortcut icon" href="~/favico.ico" />
    <link rel="bookmark" href="/favicon.ico" />
    <title>东来购物后台管理</title>
    <style type="text/css">
        .layui-tab-item {
            height: 100%;
        }
    </style>
</head>
<body class="layui-layout-body ">
    <div class="layui-layout layui-layout-admin ">
        <div class="layui-header layui-bg-green">
            <div class="layui-logo" style="box-shadow: 0 1px 2px 0 rgba(0,0,0,.15);">
                <a href="/Home/Index"><img src="~/Content/Images/icon.png" style="height: 45px;"></a>
            </div>
            <!-- 头部区域（可配合layui已有的水平导航） -->

            <ul class="layui-nav layui-layout-left ">
                <li class="layui-nav-item">
                    <div class="layui-input-inline">
                        <input type="text" name="title" lay-verify="title" autocomplete="off" placeholder="请输入搜索内容" class="layui-input"
                               style="width: 400px;height: 35px;">
                    </div>
                </li>

            </ul>
            <ul class="layui-nav layui-layout-right ">
                <li class="layui-nav-item">
                    <a href="javascript:;">
                        <img src="~/Content/Images/me.jpeg" class="layui-nav-img">
                        @{
                            var user = User as MyFormsPrincipal<UsersDtoMdel>;
                            if (user != null)
                            {
                                @user.UserData.U_LoginName
                                <span hidden id="UserID">@user.UserData.U_ID</span>
                            }
                            else
                            {
                                Context.Response.Redirect("/Home/SignIN");
                                <span>尚未登录</span>
                            }
                        }
                    </a>
                    <dl class="layui-nav-child">
                        <dd><a href="javascript:;" id="changeUserInfo">修改基本资料</a></dd>
                        <dd><a href="javascript:;" id="changeUserPwd">修改密码</a></dd>
                    </dl>
                </li>
                <li class="layui-nav-item" id="out"><a href="javascript:;">退出登录</a></li>
            </ul>
        </div>

        <div class="layui-side layui-bg-black">
            <div class="layui-side-scroll">
                <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
                <ul class="layui-nav layui-nav-tree " lay-filter="index">
                    @{
                        if (user.UserData.U_Role == 1)
                        {
                            <li class="layui-nav-item layui-nav-itemed">
                                <a class="" href="javascript:;" id="nav_index">系统管理</a>
                                <dl class="layui-nav-child">
                                    <dd><a id="/Shops/GetShop" href="javascript:;">店铺管理</a></dd>
                                    <dd><a id="/CardLevels/CardLIvels" href="javascript:;">会员等级管理</a></dd>
                                </dl>
                            </li>
                        }
                        if (user.UserData.U_Role == 2)
                        {
                            <li class="layui-nav-item layui-nav-itemed">
                                <a class="" href="javascript:;" id="nav_index">用户管理</a>
                                <dl class="layui-nav-child">
                                    <dd><a id="/User/BindUser" href="javascript:;">用户列表</a></dd>
                                </dl>
                            </li>
                            <li class="layui-nav-item">
                                <a href="javascript:;" id="nav_index">会员管理</a>
                                <dl class="layui-nav-child">
                                    <dd><a id="/Member/MemberList" href="javascript:;">会员列表</a></dd>
                                </dl>
                            </li>
                            <li class="layui-nav-item">
                                <a href="javascript:;" id="nav_index">会员消费</a>
                                <dl class="layui-nav-child">
                                    <dd><a id="/Users/MemberList1" href="javascript:;">快速消费</a></dd>
                                    <dd><a id="/Users/MemberList2" href="javascript:;">会员减积分</a></dd>
                                    <dd><a id="/Users/MemberList3" href="javascript:;">消费历史记录</a></dd>
                                </dl>
                            </li>
                            <li class="layui-nav-item">
                                <a href="javascript:;" id="nav_index">礼品管理</a>
                                <dl class="layui-nav-child">
                                    <dd><a id="/present/PreBind" href="javascript:;">礼品列表</a></dd>
                                </dl>
                            </li>
                            <li class="layui-nav-item">
                                <a href="javascript:;" id="nav_index">积分兑换</a>
                                <dl class="layui-nav-child">
                                    <dd><a href="javascript:;" id="/ExchangGift/Index">积分兑换礼品</a></dd>
                                    <dd><a href="javascript:;" id="/ConsumeOrders/Create">积分返现</a></dd>
                                    <dd><a href="javascript:;" id="/ExchangLogs/Index">兑换历史</a></dd>
                                </dl>
                            </li>
                            <li class="layui-nav-item">
                                <a href="javascript:;" id="nav_index">统计中心</a>
                                <dl class="layui-nav-child">
                                    <dd><a id="/CountSum/FastconsumeGridlView" href="javascript:;">快速消费统计</a></dd>
                                    <dd><a href="javascript:;" id="/CountSum/MemConsumGridlView">会员消费情况统计</a></dd>

                                    <dd><a href="javascript:;" id="/CountSum/JianJiFenGridlView">减积分统计</a></dd>
                                    <dd><a href="javascript:;" id="/CountSum/FanxianGridlView">积分返现统计</a></dd>
                                    <dd><a href="javascript:;" id="/CountSum/GiftIntegralView">礼品兑换统计</a></dd>
                                </dl>
                            </li>
                        }
                        if (user.UserData.U_Role == 3)
                        {
                            <li class="layui-nav-item">
                                <a href="javascript:;" id="nav_index">会员管理</a>
                                <dl class="layui-nav-child">
                                    <dd><a id="/Member/MemberList" href="javascript:;">会员列表</a></dd>
                                </dl>
                            </li>
                            <li class="layui-nav-item">
                                <a href="javascript:;" id="nav_index">会员消费</a>
                                <dl class="layui-nav-child">
                                    <dd><a id="/Users/MemberList1" href="javascript:;">快速消费</a></dd>
                                    <dd><a id="/Users/MemberList2" href="javascript:;">会员减积分</a></dd>
                                    <dd><a id="/Users/MemberList3" href="javascript:;">消费历史记录</a></dd>
                                </dl>
                            </li>
                            <li class="layui-nav-item">
                                <a href="javascript:;" id="nav_index">礼品管理</a>
                                <dl class="layui-nav-child">
                                    <dd><a id="/GiftIntegral/GiftIntegralView" href="javascript:;">礼品列表</a></dd>
                                </dl>
                            </li>
                            <li class="layui-nav-item">
                                <a href="javascript:;" id="nav_index">积分兑换</a>
                                <dl class="layui-nav-child">
                                    <dd><a href="javascript:;" id="/ExchangGift/Index">积分兑换礼品</a></dd>
                                    <dd><a href="javascript:;" id="/ConsumeOrders/Create">积分返现</a></dd>
                                    <dd><a href="javascript:;" id="/ExchangLogs/Index">兑换历史</a></dd>
                                </dl>
                            </li>
                        }
                    }
                </ul>
            </div>
        </div>

        <div class="layui-body">
            <!-- 内容主体区域 -->
            <div class="layui-tab layui-tab-card" style="position: fixed;top: 50px;z-index: 999;width: 100%; height: 100%;"
                 lay-allowclose="true" lay-filter="demo">
                <!-- 选项卡标签开始 -->
                <ul class="layui-tab-title">
                    <li lay-id='home'><i class="layui-icon layui-icon-home "></i></li>
                </ul>
                <!-- 选项卡标签结束 -->
                <!-- 选项卡内容开始 -->
                <div class="layui-tab-content" style="height:100%;">
                    <div class="layui-tab-item layui-show" style="height:1000px;">
                        <h1>首页</h1>
                    </div>
                </div>
                <!-- 选项卡内容开始 -->
            </div>
        </div>

        <div class="layui-footer">
            <!-- 底部固定区域 -->
            © layui.com - 底部固定区域
        </div>
    </div>

    <!-- js开始 -->
    <script src="https://www.layuicdn.com/layui/layui.js"></script>
    <script>
        layui.use(['element', 'layer'], function () {
            var $ = layui.jquery,
                element = layui.element, //Tab的切换功能，切换事件监听等，需要依赖element模块
                layer = layui.layer;
            var U_ID = $('#UserID').text().trim();
            $('#changeUserInfo').click(function () {
                layer.open({
                    type: 2,
                    content: ['/Users/ShowUserInfo/' + U_ID, 'no'],
                    area: ['500px', '400px'],
                    offset: ['100px', '400px'],
                    skin: 'layui-layer-molv',
                    maxmin: true,
                    id: 'lock'
                });
            })
            $('#changeUserPwd').click(function () {
                layer.open({
                    type: 2,
                    content: ['/Users/ShowChangePwd/' + U_ID, 'no'],
                    area: ['500px', '400px'],
                    offset: ['100px', '400px'],
                    skin: 'layui-layer-molv',
                    maxmin: true,
                    id: 'lock'
                });
            })

            $('#out').click(function () {
                layer.confirm('您确退出登陆吗？', { icon: 3, title: '提示' }, function (index) {
                    $.ajax({
                        url: '/Home/OutLogin',
                        type: 'get',
                        success: function (data) {
                            window.location.href = '/Home/SignIn';
                            //layer.msg(data.msg, { icon: 1 })
                        }
                    })
                })
            })
            //页面加载时,选中主页标签
            element.tabChange('demo', 'home'); //切换到：用户管理

            //监听导航点击,在官方文档中复制来的
            element.on('nav(index)', function (elem) {
                //获取所点击的行的ID
                var id = elem.attr('id');
                console.log(id);
                if (id == 'nav_index') {
                    return;
                }
                //获取到Tab上所有的标签
                var ids = $('.layui-tab-title').children('li');
                //console.log(ids)

                //定义数组,用来存储已经打开的标签页的ID
                var idarr = [];

                for (var i = 0; i < ids.length; i++) {
                    //拼接数组,拼接所有已经打开的标签页的ID值
                    idarr.push($('.layui-tab-title').children('li').eq(i).attr('lay-id'));
                }
                //判断数组中,是否包含一个指定的值,返回 -1 是未包含
                var index = idarr.indexOf(id)
                //console.log(index);

                //如果数组中未包含,则打开新的标签页
                if (index == -1) {
                    //拼接iframe字符串
                    var html = '<iframe src="' + id + '" style="width:90%;height:80%;" frameborder=0 ></ifreame>'
                    element.tabAdd('demo', {
                        title: (elem.text()), //打开的新标签页的Title
                        content: html, //打开新标签页的内容
                        id: id //打开新标签页的ID
                    })
                    //打开后,切换到新打开的标签页
                    element.tabChange('demo', id); //切换到：用户管理
                }
                //否则直接切换到已经打开的标签页上
                else {
                    element.tabChange('demo', id); //切换到：用户管理
                }
            });


        });
    </script>
</body>
</html>


